package Day07;

import java.util.Stack;

/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-09-18
 * Time: 22:36
 * To BE A Better Person-2020-3-2
 */
public class TestDemo2 {
    public static boolean chkParenthesis(String A, int n){
        if(A.equals("")) return false;
        Stack<Character> stack=new Stack<>();
        for (int i = 0; i < A.length(); i++) {
            if(A.charAt(i) == '('){
                stack.push(A.charAt(i));
            }else if(A.charAt(i) == ')'){
                if(stack.pop() != '('){
                    return false;
                }
            }else {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        String s="";
        boolean ret=chkParenthesis(s,s.length());
        System.out.println(ret);
    }
}
